# from flask import Flask
# from flask_sqlalchemy import SQLAlchemy  #导入数据库扩展，并在配置中填写相关配置
# import redis        #创建redis存储对象，并在配置中填写相关配置
# from flask_wtf.csrf import CSRFProtect  #包含请求体的请求都需要开启CSRF
# from flask_session import Session  #利用 flask-session扩展，将 session 数据保存到 Redis 中

from flask_migrate import Migrate,MigrateCommand
from flask_script import Manager
from info import create_app,db
from info import models


app = create_app('dev')
# app = Flask(__name__)

# class Config(object):
#     DEBUG = True
#     SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@192.168.65.128:3306/information"
#     SQLALCHEMY_TRACK_MODIFICATIONS = False
#
#     # redis配置
#     REDIS_HOST = "127.0.0.1"
#     REDIS_PORT = 6379
#
#     SECRET_KEY = 'sd'
#
#     # flask_session的配置信息
#     SESSION_TYPE = "redis"   # 指定 session 保存到 redis 中
#     SESSION_USE_SIGNER = True   # 让 cookie 中的 session_id 被加密签名处理


#     SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT) # 使用 redis 的实例
#     PERMANENT_SESSION_LIFETIME = 86400


# app.config.from_object(Config)
#
# #保护 如果不是客户就拒绝
# CSRFProtect(app)
#
# #实例mysql的对象
# db=SQLAlchemy(app)此处的db
#
# #设置session保存位置
# Session(app)
#
#
# redis_store = redis.StrictRedis(host=Config.REDIS_HOST,port=Config.REDIS_PORT)

# manager = Manager(app)

# 数据库迁移
Migrate(app, db)
manager = Manager(app) #建一个终端对象
manager.add_command('db',MigrateCommand)    #此处的db和上面的数据库db没有关系可以随便写只是个注释

# @app.route('/')
# def index():
#     return '叫爸爸'






if __name__ == '__main__':
    # print(app.url_map)
    manager.run()